import { Component } from "react";

import Parent from "./Parent";

import NameContext from "./NameContext";

import "./App.css";

export default class App extends Component {
  state = {
    name: "里斯",
  };

  render() {
    return (
      <NameContext.Provider value={this.state.name}>
        <div className="box">
          <p>App</p>
          <button
            onClick={() =>
              this.setState((state) => ({ name: state.name + "~" }))
            }
          >
            修改App的Name
          </button>
          <hr />
          <Parent />
        </div>
      </NameContext.Provider>
    );
  }
}
